import { BaseValue } from "../data/BaseValue";
import { Bullet } from "./Bullet";

const { ccclass, property } = cc._decorator;

@ccclass
export class BulletManager extends cc.Component {

    @property({
        type: cc.Prefab
    })
    bulletPre: cc.Prefab = null;

    /**
     * 创建子弹
     */
    public createBullet(startPos: cc.Vec2, endPos: cc.Vec2, degress: number) {
        // 未开火则不创建子弹
        if (!BaseValue.IS_FIRE || this.node.children.length > 50) {
            return;
        }
        let bullet = cc.instantiate(this.bulletPre);

        bullet.parent = this.node;
        bullet.getComponent(Bullet).setEntry(startPos, endPos, degress);
    }


}
